# !/usr/bin/env python
# -*-coding:utf-8 -*-
"""
@Author : Ayao
@Time   : 2022/5/14
@File   : 杨辉三角.py
"""
from typing import List

"""
https://leetcode.cn/leetbook/read/array-and-string/cuj3m/
"""


class Solution:
    def generate(self, numRows: int) -> List[List[int]]:
        # 按行数填充全为1的子数组
        res = [[1] * i for i in range(1, numRows + 1)]
        # 不计算每行两端值（均为1），其他值=前一行同下标-1的值+前一行同下标的值
        for m in range(2, numRows):
            for n in range(1, m):
                res[m][n] = res[m - 1][n - 1] + res[m - 1][n]
        return res


print(Solution().generate(10))
